/*!
 * @fileOverview frmwebm
 * @version 1.0.0
 *
 * @author frmstock frmstock.oicp.net freeman.cn.zhu@163.com
 * @license
 */

(function() {
	window.frmwebm || (window.frmwebm = {});
	frmwebm.prompt = function(a) {
		title = a.title ? a.title : "\u6807\u9898";
		content = a.content ? a.content : "";
		reload = a.reload ? a.reload : null;
		afterClose = a.afterClose ? a.afterClose : null;
		a = '<div class="weui_dialog_alert" style="display: none;"><div class="weui_mask"></div><div class="weui_dialog">';
		a += '<div class="weui_dialog_hd"><strong class="weui_dialog_title" style="font-size:19px;">' + title + "</strong></div>";
		a += '<div class="weui_dialog_bd" style="font-size:16px;">' + content + "</div>";
		a += '<div class="weui_dialog_ft">';
		a += '<a href="javascript:;" class="weui_btn_dialog primary">\u786e\u5b9a</a>';
		a += "</div>";
		a += "</div>";
		a += "</div>";
		var b = $(a);
		b.appendTo("body");
		b.find(".weui_btn_dialog").on("click", function() {
			b.hide();
			b.remove();
			afterClose ? window.location.href = afterClose : reload && window.location.reload(!0)
		});
		b.show()
	};
	frmwebm.confirm = function(a) {
		title = a.title ? a.title : "\u6807\u9898";
		content = a.content ? a.content : "";
		var b;
		b = '<div class="weui_dialog_confirm" style="display: none;"><div class="weui_mask"></div><div class="weui_dialog">';
		b += '<div class="weui_dialog_hd"><strong class="weui_dialog_title" style="font-size:19px;">' + title + "</strong></div>";
		b += '<div class="weui_dialog_bd" style="font-size:16px;">' + content + "</div>";
		b += '<div class="weui_dialog_ft">';
		b += '<a href="javascript:;" id="cancle" class="weui_btn_dialog default">\u53d6\u6d88</a>';
		b += '<a href="javascript:;" id="ok" class="weui_btn_dialog primary">\u786e\u5b9a</a>';
		b += "</div>";
		b += "</div>";
		b += "</div>";
		var c = $(b);
		c.appendTo("body");
		c.find("#cancle").on("click", function() {
			c.hide();
			c.remove()
		});
		c.find("#ok").on("click", function() {
			c.hide();
			c.remove();
			frmwebm.ajax(a)
		});
		c.show()
	};
	frmwebm.ajax = function(a) {
		type = a.type ? a.type : "POST";
		contentType = "undefined" == typeof a.contentType || null == a.contentType ? "application/x-www-form-urlencoded" : a.contentType;
		processData = "undefined" == typeof a.processData || null == a.processData ? !0 : a.processData;
		url = a.url ? a.url : null;
		data = a.data ? a.data : null;
		//hbhe
		dataType = a.dataType ? a.dataType : "json";
		//hbhe
		reload = a.reload ? a.reload : null;
		afterClose = a.afterClose ? a.afterClose : null;
		successFunc = a.successFunc ? a.successFunc : null;
		errorFunc = a.errorFunc ? a.errorFunc : null;
		$.ajax({
			type: type,
			contentType: contentType,
			processData: processData,
			url: url,
			// hbhe
			dataType : dataType,
			// hbhe
			data: data,
			error: function(a) {
				errorFunc && errorFunc(a)
			},
			success: function(a, c) {
				successFunc && successFunc(a)
			}
		})
	};
	frmwebm.toast = function(a) {
		var b = 0 >= arguments.length || void 0 === arguments[0] ? "toast" : arguments[0];
		a = arguments[1];
		"number" === typeof a && (a = {
			duration: a
		});
		a = $.extend({
			duration: 2E3
		}, a);
		var c = $('<div>\n            <div class="weui_mask_transparent"></div>\n            <div class="weui_toast">\n                <i class="weui_icon_toast"></i>\n                <p class="weui_toast_content">' + b + "</p>\n            </div>\n        </div>");
		$("body").append(c);
		setTimeout(function() {
			c.remove();
			c = null
		}, a.duration)
	}
})();